# $Id$
# Maintainer:
# Contributor: Andrea Scarpino <andrea@archlinux.org>
# Contributor: Tobias Powalowski <tpowa@archlinux.org>

pkgname=cfitsio
pkgver=3.420
pkgrel=1
pkgdesc="A library of C and Fortran subroutines for reading and writing data files in FITS (Flexible Image Transport System) data format"
arch=(i686 x86_64)
url="http://heasarc.gsfc.nasa.gov/fitsio/"
license=(custom)
depends=(curl)
source=("ftp://heasarc.gsfc.nasa.gov/software/fitsio/c/${pkgname}${pkgver/./}.tar.gz")
sha256sums=('6c10aa636118fa12d9a5e2e66f22c6436fb358da2af6dbf7e133c142e2ac16b8')

build() {
  cd $pkgname
  ./configure --prefix=/usr --enable-reentrant
  make shared
  make utils
}

check() {
  cd $pkgname
  LD_LIBRARY_PATH=. ./testprog > testprog.lis
  [[ -z $(diff testprog.lis testprog.out) ]] || return 1
  [[ -z $(cmp testprog.fit testprog.std) ]] || return 1
}

package() {
  cd $pkgname
  make DESTDIR="$pkgdir" install

  install -D -m644 License.txt \
    "$pkgdir"/usr/share/licenses/$pkgname/LICENSE

# Fix conflicts with ccfits and smem
  rm "$pkgdir"/usr/bin/{cookbook,smem,testprog}
}
